package com.chinatsp.onlineapp.presenter;

import android.content.Context;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import com.chinatsp.onlineapp.base.Config;
import tsp.cn.http.BaseIDao;
import tsp.cn.http.HttpConfig;
import tsp.cn.http.interfac.INetResult;
import tsp.cn.http.tools.LogUtil;
import tsp.cn.http.tools.T;

/**
 * 查询天气预报城市列表 根据关键字查询天气预报城市列表
 */

public class QueryForecastCityListDao extends BaseIDao {

	private Context context;

	public QueryForecastCityListDao(Context context, INetResult iNetResult) {
		super(context, iNetResult);
		this.context = context;
	}

	@Override
	public void onRequestSuccess(String result, int requestCode) {
		LogUtil.d( "QueryForecastCityListDao onRequestSuccess");
		//T.showShort(context, result);
	}

	/**
	 * 获取城市列表
	 * 
	 * @param keyWord
	 */
	public void getQueryForecastCityList(String keyWord) {
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append(HttpConfig.appendString());
		strBuilder.append(Config.API_QUERY_FORECAST_CITY_LIST);
		try {
			strBuilder.append(URLEncoder.encode(keyWord, "UTF-8"));
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		strBuilder.append("/");
		getRequest(strBuilder.toString(), Config.CODE_QUERY_FORECAST_CITY_LIST);
	}
}
